<!DOCTYPE HTML>
<html>
<head>
<meta name="viewport" content="width=320, user-scalable=no" />
<meta http-equiv="Content-type" content="text/html;charset=UTF-8">
<title>NFC Reader</title>
	<script type="text/javascript" charset="utf-8" src="cordova.js"></script>
	<script type="text/javascript" charset="utf-8" src="phonegap-nfc.js"></script>
	<script type="text/javascript" charset="utf-8" src="phonegap-toast.js"></script>
</head>

<body>
        <div data-role="header" data-theme="a" data-add-back-btn="true">
			<a href="index.html" data-icon="home" class="ui=btn-left">Main</a>
            <h1>Read Page</h1>
        </div>
    <h1>S-Pet NFC Reader</h1>
    <div id="tagContents">
        <div class="hidden">
            Scan a tag to being.
	       	<img src="img/nfc_logo.png">
            <h1>"휴대폰 뒷면에 S-Pet 태그를 탭해주십시오."</h1>
        </div>
    </div>

    <script id="non-ndef-template" type="text/x-handlebars-template">
        <p>Scanned a non-NDEF NFC tag</p>
        <p>
            Tag Id: <strong>{{ bytesToHexString id }}</strong>
        </p>
    </script>

    <script id="tag-template" type="text/x-handlebars-template">
        <p>Scanned an NDEF tag with {{ ndefMessage.length }} {{ pluralize ndefMessage.length 'record' 'records' }}</p>

        {{!
            BB10 and WP8 will not have any meta info
            Android P2P will not have id, but will have type
        }}
        <dl>
            {{#if id}}
            <dt>Tag Id</dt>             <dd>{{ bytesToHexString id }}</dd>
            {{/if}}
            
            {{#if type}}
            <dt>Tag Type</dt>           <dd>{{ type }}</dd>
            {{/if}}

            {{#if maxSize }}
            <dt>Max Size</dt>           <dd>{{ maxSize }} bytes</dd>
            {{/if}}            

            {{#if freeSpaceSize }}
            <dt>Free Space</dt>         <dd>{{ freeSpaceSize }} bytes</dd>
            {{/if}}

            {{#if id}}
            <dt>Is Writable</dt>        <dd>{{ toString isWritable }}</dd>
            <dt>Can Make Read Only</dt> <dd>{{ toString canMakeReadOnly }}</dd>
            {{/if}}            
        </dl>

        {{#each ndefMessage}}  {{! does not read well, iterating on records non messages}}
        <div class='record'>
            Record {{ @index }}:<br/>
            TNF: <b>{{ tnfToString tnf }}</b><br/>        
            {{#if tnf}}
                Record Type: <b>{{ bytesToString type }}</b><br/>
                Payload: <b>{{ decodePayload this }}</b><br/>
                {{#if id}}
                    Record Id: <b>{{ bytesToString id }}</b><br/>            
                {{/if}}
            {{/if}}
        </div>
        {{/each}}
    </script>
    
    <script type="text/javascript" charset="utf-8" src="js/handlebars.js"></script>
    <script type="text/javascript" charset="utf-8" src="js/read.js"></script>
    <script type="text/javascript">
        app.initialize();
    </script>
</body>
</html>
